<%-- 
    Document   : selectProduct
    Created on : 28-nov.-2011, 17:40:17
    Author     : laurent
--%>
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <fmt:setBundle basename="packageLanguage.lang" scope="session"/>       
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link href="css/tempstyle.css" rel="stylesheet" type="text/css" media="screen" />

        <title><fmt:message key = "textWindowCart"/></title>
    </head>
    
    <body>
        <div id="wrapper">
            <div id="logo">
              <jsp:include page="header.jsp"/>  
            </div>
            <hr />
            <!-- end #logo -->
            <div id="header">
		<div id="menu">
			<ul>
				<li><a href="index.jsp" class="first"><fmt:message key = "textFooterHome"/></a></li>
            			<li class="current_page_item"><a href="CatalogController"><fmt:message key = "textFooterArticles"/></a></li>
				<li><a href="about.jsp"><fmt:message key = "textFooterAbout"/></a></li>
				<li><a href="contact.jsp"><fmt:message key = "textFooterContact"/></a></li>
			</ul>
		</div>
		<!-- end #menu -->
            </div>
        
            <div id="page">
                <div id="page-bgtop">
                    <c:set var="pagename" scope="request" value="CatalogController"/>
                    <jsp:include page="langpanel.jsp"></jsp:include>

                    <div id="content">
                        <div class="post">
                            <h2 class="title"><fmt:message key = "textTitleCatalog"/></h2>
                             <div class="entry"> 
                                 <!-- ENTRY BEGINNING -->
                                 
                                 <div class="choixproduit">
                                 
                                     
                                        <form name="formCategories" action="CatalogController" method="POST">
                                            <b><fmt:message key="textChooseCateg"/>:</b>&nbsp;<select name="selectedCategory" onChange="formCategories.submit();" style="width:200px">
                                                <c:forEach var = "category" items = "${listCategories}" >
                                                    <option value="${category.id}" <c:if test = "${category.id == sessionScope.defaultCategory}">selected="selected"</c:if>>${category.name} </option>
                                                </c:forEach >
                                            </select>
                                        </form>
                                            <p/><p/>               
                                            <b><fmt:message key="textListProductsLabel"/>:</b><p/>
                                        <form name="formProducts" action="CatalogController" method="POST">
                                            <select name="selectedProduct" onChange="formProducts.submit();" size="5" style="width:200px">
                                                <c:forEach var = "product" items = "${listeProducts}" >
                                                    <option value="${product.id}"<c:if test = "${product.id == sessionScope.defaultProduct}">selected="selected"</c:if>> ${product.name} </option>
                                                </c:forEach >
                                            </select>
                                        </form>
                                            
                                </div>
                                            
                                <div class="detailproduit">
                                <!-- BEGINNING OF DETAILPRODUIT -->
                                
                                <c:if test = "${not empty productSelected}">
                                    
                                    <p/>
                                    <fieldset>
                                        <legend><fmt:message key="textProductDetailTitle" /></legend>
                                            <div>
                                                <br/>
                                                <div float="left">
                                                    
                                                        <img src="images/${productSelected.imagePath}"  TITLE="${productSelected.name}" WIDTH="150" HEIGHT="150" align="left"/>
                                
                                                </div>
                                                <div class="artTitle">
                                                    <fmt:message key="textDescription" />:<br/>
                                                </div>    
                                                    ${productSelected.description}
                                                    
                                                 <c:if test = "${empty productSelected.promotion}">
                                                    <br/><div class="artPrice"><fmt:message key="textUnitaryPrice"/>: ${productSelected.unitaryPrice} € </div>
                                                 </c:if>
                                                
                                            </div>  

                                            <c:if test = "${not empty productSelected.promotion}">
                                                <p><br/><b><fmt:message key="textPromo"/></b></p>
                                                <c:if test = "${productSelected.promotion.discountPercentage != null}">
                                                    <p><div class="artPrice">${promoPrice} € <fmt:message key="textInstead" /> ${productSelected.unitaryPrice}  €</div></p>
                                                </c:if>
                                                <c:if test = "${productSelected.promotion.discountPercentage == null}">
                                                    <p>${productSelected.promotion.quantityOffered} <fmt:message key="textProductsOfferedFor"/> ${quantityToPurchase} <fmt:message key="textProductsBought" /></p>
                                                    <p><div class="artPrice"><fmt:message key="textUnitaryPrice"/>: ${productSelected.unitaryPrice} € </div></p>
                                                    
                                                </c:if>
                                            </c:if>
                                     </fieldset>

                                    <fieldset>
                                    <legend><fmt:message key="textCommandProductTitle" /></legend>
                                    
                                    <c:if test = "${productSelected.availlable == true}" > 
                                        <form name="formQuantity" action="CatalogController" method="POST">
                                            <p><fmt:message key="textDesiredAmount" />: <select name="selectedQuantity" onChange="document.formQuantity.submit();"></p>
                                                <c:forEach var="i" begin="1" end="20">   
                                                     <option value ="${i}"<c:if test = "${i == sessionScope.defaultQuantity}">selected="selected"</c:if>>${i}</option>
                                                </c:forEach>
                                            </select>
                                            &nbsp;<fmt:message key="textCopies" />
                                                
                                            <br/>
                                            <div class="artPrice"> <fmt:message key="textTotalPrice"/>: ${priceTot}€</div>
                                            <br/>
                                            <input type="submit" value="<fmt:message key="textAddToBasket"/>" name ="addToBasket" onClick="document.formQuantity.submit();"/>
                                        </form>
                                    
                                            
                                        <p/>
                                    </c:if >  
                                        
                                    <c:if test = "${productSelected.availlable == false}" >
                                           <fmt:message key="textProductUnavailable"/>
                                    </c:if >                                         
                                        
                                    </fieldset>
                                        
                                    
                                    
                                    
                                    
                                </c:if>    
                                </div>                               
                                
                                <!-- END OF DETAILPRODUIT -->
                            
                            <!-- ENTRY END -->
                           </div> 
                            
                        </div>
                    </div>
                             
                </div>              
            </div>
                             
            <jsp:include page="footer.jsp"></jsp:include> 
            
        </div>
    </body>
</html>